Skip to content

fix: prevent unhandled ValueError for invalid slug - #781

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-1d-invalid-slug-error
Open

fix: prevent unhandled ValueError for invalid slug#781
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/cli-1d-invalid-slug-error

Conversation

@sentry

@sentry sentry Bot commented Aug 29, 2026

Copy link
Copy Markdown

This PR addresses issue CLI-1D, where the codecov create-commit command would crash with an unhandled ValueError: The provided slug is invalid if no slug was provided via --slug and no CI environment variables could supply one.

Root Cause:
The encode_slug function in codecov_cli/helpers/encoder.py was raising a bare ValueError when the input slug was None or did not conform to the expected format. As ValueError is not a click.ClickException, the Click framework could not catch and handle it gracefully, leading to an unhandled exception and CLI crash.

Solution:

  • Modified codecov_cli/helpers/encoder.py to import click.
  • Updated encode_slug to raise click.ClickException instead of ValueError when the slug is None or invalid. An explicit check for None provides a more specific error message.
  • Updated the corresponding test test_encode_invalid_slug in tests/helpers/test_encoder.py to expect click.ClickException.

Impact:
The CLI will now display a user-friendly error message and exit gracefully when a slug is missing or invalid, preventing unhandled exceptions and improving user experience.

Fixes CLI-1D

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1726 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants